import 'package:dio/dio.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

import '../../app_routes.dart';
import '../../constants/color_constant.dart';
import '../../constants/constants.dart';
import '../../core/network/model/cdn_entity.dart';
import '../../core/utils/logger.dart';
import '../../widget/CountDownButton.dart';
import '../../widget/custom_image_view.dart';
import 'dart:io';

import 'login_view.dart';

class RegisterDialog extends StatelessWidget {
  RegisterDialog();

  // Page1Controller controller = Get.find<Page1Controller>();

  var email = ''.obs;
  var password = '';
  var code = '';

  var isIconSelected = false.obs; // 协议是否选中

  var obscureText = true.obs; // 密码是否隐藏

  @override
  Widget build(BuildContext context) {
    return  new_registerView();
  }

  Widget new_registerView(){
    return SingleChildScrollView(
        child: Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(10),
                    topRight: Radius.circular(10)
                ),
                color: Colors.white
            ),
            padding: EdgeInsets.only(left: 20, right: 20, bottom: 30, top: 10),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('register account'.tr,
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold,color: Colors.black)),

                  ],
                ),

                SizedBox(height: 15,),
                TextField(
                  onChanged: (value) {
                    email.value = value;
                  },
                  style: TextStyle(color: Colors.black),
                  decoration: InputDecoration(
                    filled: true, // 背景填充
                    fillColor: ColorConstant.colorFFF5F6F9,

                    hintText: 'input email'.tr,
                    hintStyle:TextStyle(color: ColorConstant.colorFFA2A2A2),
                    contentPadding: EdgeInsets.all(15),
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10),
                      borderSide: BorderSide.none, // 边框样式
                    ),
                  ),
                ),
                SizedBox(height: 15),

                Obx(
                      () => TextField(
                    onChanged: (value) {
                      password = value;
                    },
                    style: TextStyle(color: Colors.black),
                    decoration: InputDecoration(
                      filled: true,
                      fillColor: ColorConstant.colorFFF5F6F9,
                      hintText: 'set password'.tr,
                      hintStyle:TextStyle(color: ColorConstant.colorFFA2A2A2),
                      contentPadding: EdgeInsets.all(15),
                      suffixIcon: GestureDetector(
                          onTap: () {
                            obscureText.value = !obscureText.value;
                          },
                          child: Icon(
                            obscureText.value
                                ? Icons.visibility_off
                                : Icons.visibility, // 密码可见性切换图标
                          )),
                      // 密码可见性切换图标
                      border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(10),
                        borderSide: BorderSide.none,
                      ),
                    ),
                    obscureText: obscureText.value, // 密码隐藏
                  ),
                ),
                //带倒计时按钮的输入框

                SizedBox(height: 20),
                //注册即代表您已阅读并同意《用户协议》和《隐私政策》

                GestureDetector(
                  onTap: () {
                    if (email.value.isEmpty || password.isEmpty) {
                      Fluttertoast.showToast(
                        msg: 'Enter the complete content',
                      );
                      return;
                    }
                    Get.back();
                    Get.bottomSheet(isScrollControlled:true,LoginDialog());
                  },
                  child: Container(
                      height: 40,
                      // width: 140,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(5),
                        gradient: LinearGradient(
                          colors: [
                            ColorConstant.colorFFD405EF,
                            ColorConstant.colorFF052BFD
                          ],
                          begin: Alignment.centerLeft, // 渐变色开始位置
                          end: Alignment.centerRight, // 渐变色结束位置
                        ),
                      ),
                      alignment: Alignment.center,
                      child: Text(
                        'account register'.tr,
                        style: TextStyle(fontSize: 14,color: Colors.white),
                      )),
                ),

                SizedBox(height: 20), // 用于添加间隔
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text('have account?'.tr,style: TextStyle(color: ColorConstant.text_grey),),
                    GestureDetector(
                      onTap: () {
                        Get.back();
                        Get.bottomSheet(isScrollControlled:true,LoginDialog());
                      },
                      child: Text(
                        "goto login".tr,
                        style: TextStyle(
                            color: ColorConstant.colorFFAD4AFF,
                            fontSize: 15,
                            decoration: TextDecoration.underline,
                            decorationColor: ColorConstant.colorFFAD4AFF),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 30),
              ],// 使内容尽量紧凑
            )
        )
    );
  }
  Future<void> fetchAgreements() async {
    try {


    } catch (e) {
      print(e);
      throw Exception('Failed to load agreements');
    }
  }

}
